/**
 * Created by Administrator on 2016/5/24.
 */

require(["jquery", "log", "rnetworking", "thisPlugins","utils","util"], function ($, log, rnetworking, plugins,utils,util) {
    $(function () {
        $("#btnLogin").click(function () {
            var loginName = $("#logName").val();
            var password = $("#password").val();
            if (loginName == "") {
                $("#loginSpan").html("用户名不能为空！");
                return false;
            }
            if (password == "") {
                $("#passwordSpan").html("密码不能为空！");
                return false;
            }
           var loginSel=rnetworking.create();
            loginSel.addParams("loginName", loginName)
            loginSel.addParams("password", MD5(password))
            loginSel.ajax(utils.getIP()+"powerUser/getPowerLoginUsers", function (data) {
                    if (data.success) {
                        plugins.saveLoginUser(data.rows[0]);
                        window.location.href = "index.html";
                    } else {
                        log.alert("用户名或密码错误");
                    }
                });

        });

    });
});